<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.wxtf.platform.plugins.user.*"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	UserBean user = (UserBean)request.getSession().getAttribute("userBean");
	String _db = user.getDbType();	
	   
	    Map<String,List<Map<String, String>>> dicMap = user.getDicMap();
	    List<Map<String, String>> list = null;
	    List<Map<String, String>> list1 = null;
	    String temp = "";	
	    String tbe_marital_status = "";//婚姻状态
	    String tbe_nation = "";//民族
	    String tbcsr_type = "";//手术类型
	    list = null;
	    list = dicMap.get("27");
	    if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_marital_status += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	    }
	    list = null;
	    list = dicMap.get("5");
	    if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_nation += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	    }
	    list = null;
	    list = dicMap.get("109");
	    if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbcsr_type += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	    }
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>"/>
		<title>现有独生子女职工名单</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta http-equiv="pragma" content="no-cache"/>
		<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="expires" content="0"/>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

		<link type="text/css" rel="stylesheet" href="ligerUI/skins/Aqua/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/<%=user.getUserCss()%>/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/ligerui-icons.css" />
		<link type="text/css" rel="stylesheet" href="resource/css/style.css" />

		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="ligerUI/js/core/base.js"></script>
		<script type="text/javascript" src="ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/validata.js"></script>

		<script type="text/javascript" src="ligerUI/js/plugins/ligerGrid.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerTree.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerForm.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerDateEditor.js"></script>
		
		<script type="text/javascript" src="ligerUI/jquery-validation/jquery.validate.min.js" ></script> 
		<script type="text/javascript" src="ligerUI/jquery-validation/jquery.metadata.js"></script>
		<script type="text/javascript" src="ligerUI/jquery-validation/messages_cn.js" ></script>
		
<script type="text/javascript">
var _db = '<%=_db%>';

_jsonObj.classname = "com.wxtf.platform.main.proprietaryInquires.Employee";
_jsonObj.methodname = "";
_jsonObj.logicdata = '';


var win;
var manager;


$(function(){
	manager = $("#emp-grid").ligerGrid({
		url: _url, parms: _jsonObj, width: '100%', height: '100%',
		usePager: true, rownumbers: true, checkbox: false, alternatingRow: true,
		columns: [
			
			{ display: '机构', name: 'reserve1',id:'reserve1', width:100,isSort:false},
			{ display: 'org_id', name: 'org_id',id:'org_id', hide: true,width:1 },
			{ display: '组织机构', name: 'tbe_name',id:'tbe_name',width:100 },
			{ display: '姓名', name: 'tbe_name',id:'tbe_name',width:100 },
			{ display: '身份证号', name: 'tbe_idcard',id:'tbe_idcard',width:180 },
			{ display: '性别', name: 'tbe_sex',id:'tbe_sex', width:50 },
			{ display: '年龄', name: 'tbe_age',id:'tbe_age',width:1,hide:true},
			{ display: '民族', name: 'tbe_nation',id:'tbe_nation',width:80,
			      render: function(record, index, value, oth){
						 <%
						list = dicMap.get("5");
						temp = "";
						if(null != list && list.size() > 0){
							for(Map<String, String> map: list){
						%>
						if(value == '<%=map.get("tmgd_id")%>'){
							<%
							temp = map.get("tmgd_name");
							%>
							return '<%=temp%>';
						}
						<%
							}
						}
						%>
						 return value;
					}
			},
			{ display: '出生日期', name: 'tbe_birthday',id:'tbe_birthday',width:100 },
			{ display: '职级', name: 'tbe_position',id:'tbe_position', width:100,
			      render: function(record, index, value, oth){
			         if(record.tbe_position =='1')  {return "专业技术管理";}
			         if(record.tbe_position =='2')  {return "生产操作服务";}
 			      }
			 },
			{ display: '工龄', name: 'tbe_seniority',id:'tbe_seniority',width:1,hide:true },
			
			{ display: '配偶姓名', name: 'tbfi_spouse_name',id:'tbfi_spouse_name',width:80},
			{ display: '配偶性别', name: 'tbfi_spouse_sex',id:'tbfi_spouse_sex',width:80},
			{ display: '配偶单位', name: 'tbfi_spouse_department',id:'tbfi_spouse_department',width:100},
			
			
			{ display: '婚姻状态', name: 'tbe_marital_status',id:'tbe_marital_status',width:80,
			       render: function(record, index, value, oth){
						 <%
						list = dicMap.get("27");
						temp = "";
						if(null != list && list.size() > 0){
							for(Map<String, String> map: list){
						%>
						if(value == '<%=map.get("tmgd_id")%>'){
							<%
							temp = map.get("tmgd_name");
							%>
							return '<%=temp%>';
						}
						<%
							}
						}
						%>
						 return value;
					}
			 },
			{ display: '子女状况', name: 'tbe_children_status',id:'tbe_children_status',width:1, hide: true },
			{ display: '持证情况', name: 'chizheng',id:'chizheng',width:80,isSort:false,
			     render: function(record, index, value, oth){
			        return  record.chizheng=="0"?"无":value+"张";
			     }
			},
			{ display: '节育史', name: '',id:'',width:100,isSort:false,render: function(record, index, value, oth){
					return " <a href='javascript:viewData(" + JSON.stringify(record) + ")'>查看节育史</a>";
				} 
			}
			

		]
		
	});

	/*
	 * 日期框
	 */
	$("#ser_from").ligerDateEditor({ format: "yyyy-MM-dd", width:182 });
	$("#ser_to").ligerDateEditor({ format: "yyyy-MM-dd", width:182});
});

/*
 * 表格刷新
 */
function reload(){
	_jsonObj.methodname = "queryPage";
	_jsonObj.logicdata = "[{\"types\":\"init\"}]";
	manager.loadData();
}
/*
 * ajax成功回调
 */
function ajaxCallbackSuccFunc(data, textStatus){
	if(win){
		win.hide();
	}
	succMsgTip(data.resultrecord);
	reload();
}

/*
 * ajax失败回调
 */
function ajaxCallbackErrorFunc(data, textStatus){
	warningTip(data.resultrecord);
}




/*
 * 重置-条件查询
 */
function serReset(){
	$('#ser_from').val('');
	$('#ser_to').val('');
	//$('#ser_org').val('');
}

/*
 * 条件查询
 */
function serch1(){
	var ser_from = $('#ser_from').val();
	var ser_to = $('#ser_to').val();
    var ser_org= $('#ser_org').val();
	_jsonObj.methodname = "queryPage";
	_jsonObj.logicdata = '[{\"ser_from\":\"' + ser_from	+ '\",\"ser_to\":\"' + ser_to+ '\",\"type\":\"tj_ser\",\"ser_org\":\"'+ ser_org+'\"}]';
	manager.loadData();
}

/*
 * 时间验证
 */
function joinTime(ele){
	var ser_from = $('#ser_from').val();
	var ser_to = $('#ser_to').val();
	if('' != ser_from && '' != ser_to){
		var res = compareDate(ser_from, ser_to);
		if(null == res || res >= 0){
			ele.value = '';
			warningTip('时间有误！');
			return;
		}
	}
}

var jieyu_manager;
function viewData(row){
	if(win == null){
		win = initWindowByDiv2('emp-div', '员工节育史', 1010, 480, closeWin);
	} else {
		win.show();
	}
	
	$("#tab-div").ligerTab({
		dblClickToClose: false
	});
    
    $('#reserve1').html(row.reserve1);
	$('#tbe_name').html(row.tbe_name);
	$('#tbe_idcard').html(row.tbe_idcard);
	$('#tbe_sex').html(row.tbe_sex);
	$('#tbe_birthday').html(row.tbe_birthday);
	$('#tbe_nation').html(getDicNameById1(row.tbe_nation));
	$('#tbe_position').html(zhiji(row.tbe_position));
	$('#tbe_marital_status').html(getDicNameById2(row.tbe_marital_status));

	param_shengyushi = { 
				"classname": "com.wxtf.platform.main.proprietaryInquires.Employee",
				"methodname": "query1",
				"logicdata":'[{\"tbe_id\":\"' + row.tbe_id + '\"}]',
				"extenddata": "[]"
			};
        
        jieyu_manager = $("#jieyu-grid").ligerGrid({
		url: _url, parms: param_shengyushi, width: '100%', height: '280',
		usePager: true, rownumbers: true, checkbox:false, alternatingRow: true,
		columns: [
			{ display: '手术时间', name: 'tbcsr_time',id:'tbcsr_time',width:100 },
			{ display: '手术类型', name: 'tbcsr_type',id:'tbcsr_type', width:150,
			     render: function(record, index, value, oth){
					<%
					list = dicMap.get("109");
					list1 = dicMap.get("110");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
				
					if(null != list1 && list1.size() > 0){
						for(Map<String, String> map: list1){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
					%>
					return value==0?"无":value;
				}
			 },
			{ display: '手术医院', name: 'tbcsr_hospital',id:'tbcsr_hospital',width:150 },
			{ display: '手术地点', name: 'tbcsr_place',id:'tbcsr_place',width:300 },
			{ display: '手术医生', name: 'tbcsr_doctor',id:'tbcsr_doctor',width:100 },
			{ display: '术后状况', name: 'tbcsr_description',id:'tbcsr_description',width:150 }
		]
	});
    
}

//民族
function getDicNameById1(id){
	<%
	list = dicMap.get("5");
	temp = "";
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
	%>
	if(id == '<%=map.get("tmgd_id")%>'){
		<%temp = map.get("tmgd_name");%>
		return '<%=temp%>';
	}
	<%}}%>
	return id;
}
//婚姻状态
function getDicNameById2(id){
	<%
	list = dicMap.get("27");
	temp = "";
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
	%>
	if(id == '<%=map.get("tmgd_id")%>'){
		<%temp = map.get("tmgd_name");%>
		return '<%=temp%>';
	}
	<%}}%>
	return id;
}
//职级
function zhiji(id){
  if("1"==id){return "专业技术管理";}
  if("2"==id){return "生产操作服务";}
}

</script>
</head>
	<body>
	 

        <div tabid="home1"  style="height:300px" >
		<table id="aaa" class="serTable">
			
			<tr>
				<td>机构：</td>
				<td>
					<select id="ser_org" style=" width: 180px;">
						<%=user.getCurSubOrgOptions()%>
					</select>
				</td>
				<td></td>
				<td></td>
				<td><input class="btn2" value="重置" type="button" onclick="serReset();" /></td>
				</tr>
				<tr>
				<td>出生日期：</td>
				<td><input id="ser_from" onChange='joinTime(this);' onkeyup="this.value=formatdata(this.value);"/></td>
				<td>-</td>
				<td><input id="ser_to" onChange='joinTime(this);' onkeyup="this.value=formatdata(this.value);"/></td>
				<td><input class="btn2" value="搜索" type="button" onclick="serch1();" /></td>
				
			</tr>
		</table>
		
		<div id="emp-grid"></div>
		</div>
		
		
		<div id="emp-div" style="display: none;">
			<form id="form0" name="form0" style=" margin-right: 7px;">
				<table class="table-style">
					<tr>
						<th>组织机构</th><td style="width: 230px;" id="reserve1"></td>
					    <th>姓名</th><td style="width: 230px;" id="tbe_name"></td>
					    <th>身份证号</th><td style="width: 230px;" id="tbe_idcard"></td>
					</tr>
					<tr>
						<th>性别</th><td id="tbe_sex"></td>
					    <th>出生日期</th><td id="tbe_birthday"></td>
					    <th>民族</th><td id="tbe_nation"></td>
					</tr>
					<tr>
						<th>职级</th><td id="tbe_position"></td>
					    <th>婚姻状态</th><td id="tbe_marital_status"></td>
					    <th></th><td></td>
					</tr>
				</table>
			</form>
		    <div id="tab-div" style="margin-top:3px; margin-right: 7px;">
				<div title="节育史">
					
					<div id="jieyu-grid"></div>
					<!--  
					<form id="form1" name="form1">
						<table id="shengyu-table" class="table-style">
							<tr>
								<th>生育时间</th>
								<th>孩子姓名</th>
								<th>孩子性别</th>
								<th>孩子身份证号</th>									
		                    </tr>
						</table>
					</form>
					-->
				</div>
				
				</div>	
		</div>
		
	</body>
</html>